﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="edit_check_admin.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.edit_check_admin" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <%
        int id = int.Parse(Request.QueryString["id"]);

        var get_check = new TblCheckManagerController().FetchAll().Where(x => x.Id == id).Single();
        var get_admin = new TblManagerController().FetchAll().Where(x => x.ManagerId == get_check.ManagerId).Single();
        var get_role = new TblManagerRoleController().FetchAll().Where(x => x.RoleId == get_admin.Role).Single();
    %>
    <div class="checkinout-edit-modal w3-modal-content w3-animate-top w3-card-8 w3-white">
        <header class="w3-center w3-padding w3-large w3-blue">
            <i class="fa fa-pencil"></i>&nbsp;Chỉnh sửa điểm danh<a href="javascript:;" class="w3-right w3-text-white" title="Đóng"><span onclick="$('#suadiemdanh').fadeOut()"><i class="fa fa-times"></i></span></a>
        </header>
        <div class=" w3-responsive">
            <table class="w3-table">
                <tr>
                    <td class="checkinout-img w3-hide-small">
                        <img src="../Content/avatar/<%=get_admin.Avatar %>" class="w3-circle" alt="Avatar" />
                    </td>
                    <td>
                        <label><%=get_admin.FullName %></label><br />
                        <span class="w3-text-grey w3-hide-small"><%=get_role.RoleName %></span>
                    </td>
                    <%string checkin, checkout = "";
                      string checkin_day = DateTime.Parse(get_check.CheckIn.ToString()).Day.ToString();
                      string checkin_month = DateTime.Parse(get_check.CheckIn.ToString()).Month.ToString();
                      string checkin_hour = DateTime.Parse(get_check.CheckIn.ToString()).Hour.ToString();
                      string checkin_minute = DateTime.Parse(get_check.CheckIn.ToString()).Minute.ToString();
                      if (int.Parse(checkin_day) < 10)
                          checkin_day = "0" + checkin_day;
                      if (int.Parse(checkin_month) < 10)
                          checkin_month = "0" + checkin_month;
                      if (int.Parse(checkin_hour) < 10)
                          checkin_hour = "0" + checkin_hour;
                      if (int.Parse(checkin_minute) < 10)
                          checkin_minute = "0" + checkin_minute;
                      checkin = DateTime.Parse(get_check.CheckIn.ToString()).Year.ToString() + "-" + checkin_month + "-" + checkin_day + "T" + checkin_hour + ":" + checkin_minute;

                      if (!String.IsNullOrEmpty(get_check.CheckOut.ToString()))
                      {
                          string checkout_day = DateTime.Parse(get_check.CheckOut.ToString()).Day.ToString();
                          string checkout_month = DateTime.Parse(get_check.CheckOut.ToString()).Month.ToString();
                          string checkout_hour = DateTime.Parse(get_check.CheckOut.ToString()).Hour.ToString();
                          string checkout_minute = DateTime.Parse(get_check.CheckOut.ToString()).Minute.ToString();

                          if (int.Parse(checkout_day) < 10)
                              checkout_day = "0" + checkout_day;
                          if (int.Parse(checkout_month) < 10)
                              checkout_month = "0" + checkout_month;
                          if (int.Parse(checkout_hour) < 10)
                              checkout_hour = "0" + checkout_hour;
                          if (int.Parse(checkout_minute) < 10)
                              checkout_minute = "0" + checkout_minute;
                          checkout = DateTime.Parse(get_check.CheckOut.ToString()).Year.ToString() + "-" + checkout_month + "-" + checkout_day + "T" + checkout_hour + ":" + checkout_minute;
                      } 
                    %>
                    <td>
                        <label class="time-ship">Giờ làm&nbsp;&nbsp;<i title="Giờ làm" data-toggle="popover" data-trigger="hover" data-content="Sáng: 8:00 - 11:30  Chiều: 13:30 - 17:00  Tối: 17:30 - 21:00" class="fa fa-info-circle w3-hover-text-blue"></i></label><br />
                        <input id="edit_checkin" type="datetime-local" value="<%=checkin %>" class="checkinout-date" />
                    </td>
                    <td>
                        <label>Vắng</label><br />
                        <div class="checkbox">
                            <input <%if (get_check.Absent == true)
                                     { %>checked="checked"
                                <%} %> type="checkbox" id="absent-edit" />&nbsp;<label for="absent-edit" style="bottom: 8px !important"></label>
                        </div>
                    </td>
                    <td>
                        <label>Tăng ca</label><br />
                        <div class="checkbox">
                            <input <%if (get_check.OverTime == true)
                                     { %>checked="checked"
                                <%} %> type="checkbox" id="overtime" />&nbsp;<label for="overtime" style="bottom: 8px !important"></label>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div class="w3-row w3-center w3-padding-8">
            <a class="btn_edited_check w3-btn w3-blue"><i class="fa fa-save"></i>&nbsp;Lưu</a>
            <a onclick="$('#suadiemdanh').fadeOut()" class="w3-btn w3-blue"><i class="fa fa-times"></i>&nbsp;Hủy</a>
        </div>
    </div>
</body>
</html>
